package com.itheima.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Description:
 *
 * @author codermao
 * @date 2023/11/5 16:44
 *
 *  TODO：RequestMapping
 *
 *    1.编写位置
 *      1）类上：用于窄化路径,访问此类中的方法必须经过此路径
 *      2）方法上：此方法的访问路径
 *
 *    2.常用属性
 *        1. value或者path: 用来指定虚拟路径,value=可以省略
 *        2. method: 用来限定请求的方式   (restful风格)
 *            1). 不写,默认什么请求方式都可以
 *            2). 写了,指定了请求方式,如果不匹配就会响应405状态码(错误)
 */
@Controller
@RequestMapping("/user")
public class HelloController {

    @RequestMapping(path = "/hello",method = RequestMethod.GET)
    @ResponseBody
    public String hello(){
        System.out.println("hello springmvc...");
        return "hello springmvc get";
    }

    @RequestMapping(path = "/hello",method = RequestMethod.POST)
    @ResponseBody
    public String hello2(){
        System.out.println("hello springmvc...");
        return "hello springmvc post";
    }


    @RequestMapping("/delete")
    @ResponseBody
    public String delete(){
        System.out.println("hello springmvc delete");
        return "hello springmvc delete";
    }

}
